<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>仪表板 - 用户管理系统</title>
    <link rel="stylesheet" href="/static/css/style.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
    <style>
        .sidebar {
            min-height: 100vh;
            background-color: #212529;
            color: white;
        }
        .nav-link {
            color: rgba(255, 255, 255, 0.8);
            border-radius: 0.25rem;
            margin-bottom: 0.5rem;
        }
        .nav-link:hover, .nav-link.active {
            color: white;
            background-color: rgba(255, 255, 255, 0.1);
        }
        .welcome-card {
            background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
            color: white;
            border-radius: 0.5rem;
        }
    </style>
</head>
<body>
    <div class="container-fluid">
        <div class="row">
            <!-- 侧边栏 -->
            <div class="col-md-3 col-lg-2 d-md-block sidebar collapse p-3">
                <div class="text-center mb-4 mt-3">
                    <h4>用户管理系统</h4>
                </div>
                <hr>
                <ul class="nav flex-column">
                    <li class="nav-item">
                        <a class="nav-link active" href="#">
                            <i class="bi bi-speedometer2 me-2"></i> 仪表板
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#">
                            <i class="bi bi-person me-2"></i> 用户管理
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#">
                            <i class="bi bi-gear me-2"></i> 设置
                        </a>
                    </li>
                    <li class="nav-item mt-5">
                        <a class="nav-link text-danger" href="#" id="logout-btn">
                            <i class="bi bi-box-arrow-right me-2"></i> 退出登录
                        </a>
                    </li>
                </ul>
            </div>

            <!-- 主内容区 -->
            <main class="col-md-9 ms-sm-auto col-lg-10 px-md-4 py-4">
                <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                    <h1 class="h2">仪表板</h1>
                    <div class="btn-toolbar mb-2 mb-md-0">
                        <div class="btn-group me-2">
                            <button type="button" class="btn btn-sm btn-outline-secondary">导出</button>
                            <button type="button" class="btn btn-sm btn-outline-secondary">打印</button>
                        </div>
                    </div>
                </div>

                <!-- 欢迎卡片 -->
                <div class="card welcome-card mb-4 p-4">
                    <div class="card-body">
                        <h4 class="card-title">欢迎回来，<span id="user-name">用户</span>！</h4>
                        <p class="card-text">您已成功登录到用户管理系统。</p>
                    </div>
                </div>

                <!-- 统计卡片 -->
                <div class="row">
                    <div class="col-md-4 mb-4">
                        <div class="card border-0 shadow-sm h-100">
                            <div class="card-body">
                                <h5 class="card-title">活跃用户</h5>
                                <h2 class="display-6 fw-bold">98</h2>
                                <p class="text-muted">较上月增长 12%</p>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-4 mb-4">
                        <div class="card border-0 shadow-sm h-100">
                            <div class="card-body">
                                <h5 class="card-title">新注册用户</h5>
                                <h2 class="display-6 fw-bold">24</h2>
                                <p class="text-muted">本月新增</p>
                            </div>
                        </div>
                    </div>
                </div>
            </main>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="/static/js/auth.js"></script>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 检查用户是否已登录
            if (!isAuthenticated()) {
                window.location.href = '/';
                return;
            }
            
            // 显示用户名
            const user = getCurrentUser();
            if (user) {
                document.getElementById('user-name').textContent = user.username;
            }
            
            // 登出按钮事件
            document.getElementById('logout-btn').addEventListener('click', function(e) {
                e.preventDefault();
                logout();
            });
        });
    </script>
</body>
</html> class="card-body">
                                <h5 class="card-title">总用户数</h5>
                                <h2 class="display-6 fw-bold">125</h2>
                                <p class="text-muted">较上月增长 5%</p>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-4 mb-4">
                        <div class="card border-0 shadow-sm h-100">
                            <div class="card-body">
                                <h5 class="card-title">活跃用户</h5>
                                <h2 class="display-6 fw-bold">98</h2>
                                <p class="text-muted">较上月增长 12%</p>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-4 mb-4">
                        <div class="card border-0 shadow-sm h-100">
                            <div class="card-body">
                                <h5 class="card-title">新注册用户</h5>
                                <h2 class="display-6 fw-bold">24</h2>
                                <p class="text-muted">本月新增</p>
                            </div>
                        </div>
                    </div>
                </div>
            </main>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="/static/js/auth.js"></script>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 检查用户是否已登录
            if (!isAuthenticated()) {
                window.location.href = '/';
                return;
            }
            
            // 显示用户名
            const user = getCurrentUser();
            if (user) {
                document.getElementById('user-name').textContent = user.username;
            }
            
            // 登出按钮事件
            document.getElementById('logout-btn').addEventListener('click', function(e) {
                e.preventDefault();
                logout();
            });
        });
    </script>
</body>
</html>